package org.bedracket.pgeg.init;

import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.*;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import org.bedracket.pgeg.PGEGMod;
import org.bedracket.pgeg.item.*;

import java.util.Locale;
import java.util.function.Supplier;

public class ModItems {

    public static final DeferredRegister<Item> ITEMS =
            DeferredRegister.create(ForgeRegistries.ITEMS, PGEGMod.MOD_ID);

    /*Magic Items*/
    public static final RegistryObject<Item> MANA_CRYSTAL_DUST =
            register("mana_crystal_dust", ManaDustItem::new);

    /*Food Items*/
    public static final RegistryObject<Item> BROWNIE =
            register("brownie", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> DOUGH =
            register("dough", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> BURRITO_BEEF =
            register("burrito_beef", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> BURRITO_FISH =
            register("burrito_fish", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> BURRITO_VEGGIE =
            register("burrito_veggie", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> CARAMEL =
            register("caramel", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> CARAMEL_APPLE =
            register("caramel_apple", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> COOKIE_CAT =
            register("cookie_cat", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> CREAM_COOKIE =
            register("cream_cookie", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> CARAMEL_DONUT =
            register("caramel_donut", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> SUGAR_DONUT =
            register("sugar_donut", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> CHEESE =
            register("cheese", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> CHEESE_FRIES =
            register("cheese_fries", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> BERRY_JELLY =
            register("berry_jelly", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> LION_LICKER =
            register("lion_licker", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> BERRY =
            register("berry", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> NIGIRI_COD =
            register("nigiri_cod", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> NIGIRI_SALMON =
            register("nigiri_salmon", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> NIGIRI_SQUID =
            register("nigiri_squid", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> ONIGIRI =
            register("onigiri", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> APPLE_PIE =
            register("apple_pie", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> CHOCOLATE_PIE =
            register("chocolate_pie", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> BERRY_PIE =
            register("berry_pie", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> SLIME_PIE =
            register("slime_pie", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> RAW_SQUID =
            register("raw_squid", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> COOKED_SQUID =
            register("cooked_squid", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> TOMATO =
            register("tomato", () ->
                    new FoodSeedItem(ModBlocks.TOMATO.get(), 2, 0.2F));
    public static final RegistryObject<Item> RICE =
            register("rice", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> NIGIRI_TROPICAL =
            register("nigiri_tropical", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> ROLL_SEA_PICKLE =
            register("roll_sea_pickle", () ->
                    new FoodItem(2, 0.2F));
    public static final RegistryObject<Item> BACON =
            register("bacon", () ->
                    new FoodItem(4, 0.3F));


    /*Materials*/
    public static final RegistryObject<Item> ORICHALCUM_INGOT =
            register("orichalcum_ingot", () ->
                    new Item(new Item.Properties()));
    public static final RegistryObject<Item> SATURNIUM_INGOT =
            register("saturnium_ingot", () ->
                    new Item(new Item.Properties()));
    public static final RegistryObject<Item> BRIMSTONE_INGOT =
            register("brimstone_ingot", () ->
                    new Item(new Item.Properties()));
    public static final RegistryObject<Item> METEORITE_INGOT =
            register("meteorite_ingot", () ->
                    new Item(new Item.Properties()));
    public static final RegistryObject<Item> MITHRIL_INGOT =
            register("mithril_ingot", () ->
                    new Item(new Item.Properties()));
    public static final RegistryObject<Item> SILVER_INGOT =
            register("silver_ingot", () ->
                    new Item(new Item.Properties()));
    public static final RegistryObject<Item> AIR_SHARD =
            register("air_shard", () ->
                    new Item(new Item.Properties()));

    public static final RegistryObject<Item> AQUA_SHARD =
            register("aqua_shard", () ->
                    new Item(new Item.Properties()));

    public static final RegistryObject<Item> EARTH_SHARD =
            register("earth_shard", () ->
                    new Item(new Item.Properties()));

    public static final RegistryObject<Item> ENTROPY_SHARD =
            register("entropy_shard", () ->
                    new Item(new Item.Properties()));

    public static final RegistryObject<Item> FIRE_SHARD =
            register("fire_shard", () ->
                    new Item(new Item.Properties()));

    public static final RegistryObject<Item> ORDER_SHARD =
            register("order_shard", () ->
                    new Item(new Item.Properties()));

    /*Tools*/
    public static final RegistryObject<Item> ORICHALCUM_PICKAXE =
            register("orichalcum_pickaxe", () ->
                    new PickaxeItem(EModTiers.ORICHALCUM, 1, -2.8F, new Item.Properties()));
    public static final RegistryObject<Item> SATURNIUM_PICKAXE =
            register("saturnium_pickaxe", () ->
                    new PickaxeItem(EModTiers.SATURNIUM, 1, -2.8F, new Item.Properties()));
    public static final RegistryObject<Item> BRIMSTONE_PICKAXE =
            register("brimstone_pickaxe", () ->
                    new PickaxeItem(EModTiers.BRIMSTONE, 1, -2.8F, new Item.Properties()));
    public static final RegistryObject<Item> METEORITE_PICKAXE =
            register("meteorite_pickaxe", () ->
                    new PickaxeItem(EModTiers.METEORITE, 1, -2.8F, new Item.Properties()));
    public static final RegistryObject<Item> MITHRIL_PICKAXE =
            register("mithril_pickaxe", () ->
                    new PickaxeItem(EModTiers.MITHRIL, 1, -2.8F, new Item.Properties()));
    public static final RegistryObject<Item> SILVER_PICKAXE =
            register("silver_pickaxe", () ->
                    new PickaxeItem(EModTiers.SILVER, 1, -2.8F, new Item.Properties()));

    public static final RegistryObject<Item> ORICHALCUM_SHOVEL =
            register("orichalcum_shovel", () ->
                    new ShovelItem(EModTiers.ORICHALCUM, 1.5f, -3F, new Item.Properties()));
    public static final RegistryObject<Item> SATURNIUM_SHOVEL =
            register("saturnium_shovel", () ->
                    new ShovelItem(EModTiers.SATURNIUM, 1.5f, -3F, new Item.Properties()));
    public static final RegistryObject<Item> BRIMSTONE_SHOVEL =
            register("brimstone_shovel", () ->
                    new ShovelItem(EModTiers.BRIMSTONE, 1.5f, -3F, new Item.Properties()));
    public static final RegistryObject<Item> METEORITE_SHOVEL =
            register("meteorite_shovel", () ->
                    new ShovelItem(EModTiers.METEORITE, 1.5f, -3F, new Item.Properties()));
    public static final RegistryObject<Item> MITHRIL_SHOVEL =
            register("mithril_shovel", () ->
                    new ShovelItem(EModTiers.MITHRIL, 1.5f, -3F, new Item.Properties()));
    public static final RegistryObject<Item> SILVER_SHOVEL =
            register("silver_shovel", () ->
                    new ShovelItem(EModTiers.SILVER, 1.5f, -3F, new Item.Properties()));

    public static final RegistryObject<Item> ORICHALCUM_HOE =
            register("orichalcum_hoe", () ->
                    new HoeItem(EModTiers.ORICHALCUM,1, -3F, new Item.Properties()));
    public static final RegistryObject<Item> SATURNIUM_HOE =
            register("saturnium_hoe", () ->
                    new HoeItem(EModTiers.SATURNIUM, 2, -3F, new Item.Properties()));
    public static final RegistryObject<Item> BRIMSTONE_HOE =
            register("brimstone_hoe", () ->
                    new HoeItem(EModTiers.BRIMSTONE,1, -3F, new Item.Properties()));
    public static final RegistryObject<Item> METEORITE_HOE =
            register("meteorite_hoe", () ->
                    new HoeItem(EModTiers.METEORITE,3, -3F, new Item.Properties()));
    public static final RegistryObject<Item> MITHRIL_HOE =
            register("mithril_hoe", () ->
                    new HoeItem(EModTiers.MITHRIL,1, -3F, new Item.Properties()));
    public static final RegistryObject<Item> SILVER_HOE =
            register("silver_hoe", () ->
                    new HoeItem(EModTiers.SILVER,1, -3F, new Item.Properties()));


    public static final RegistryObject<Item> ORICHALCUM_AXE =
            register("orichalcum_axe", () ->
                    new AxeItem(EModTiers.ORICHALCUM,6, -3F, new Item.Properties()));
    public static final RegistryObject<Item> SATURNIUM_AXE =
            register("saturnium_axe", () ->
                    new AxeItem(EModTiers.SATURNIUM, 6.0f, -3F, new Item.Properties()));
    public static final RegistryObject<Item> BRIMSTONE_AXE =
            register("brimstone_axe", () ->
                    new AxeItem(EModTiers.BRIMSTONE,5, -3F, new Item.Properties()));
    public static final RegistryObject<Item> METEORITE_AXE =
            register("meteorite_axe", () ->
                    new AxeItem(EModTiers.METEORITE,7, -3F, new Item.Properties()));
    public static final RegistryObject<Item> MITHRIL_AXE =
            register("mithril_axe", () ->
                    new AxeItem(EModTiers.MITHRIL,5, -3F, new Item.Properties()));
    public static final RegistryObject<Item> SILVER_AXE =
            register("silver_axe", () ->
                    new AxeItem(EModTiers.SILVER,5, -3F, new Item.Properties()));

    public static final RegistryObject<Item> ORICHALCUM_SHEARS =
            register("orichalcum_shears", () ->
                    new ShearsItem(new Item.Properties()));
    public static final RegistryObject<Item> SATURNIUM_SHEARS =
            register("saturnium_shears", () ->
                    new ShearsItem(new Item.Properties()));
    public static final RegistryObject<Item> BRIMSTONE_SHEARS =
            register("brimstone_shears", () ->
                    new ShearsItem(new Item.Properties()));
    public static final RegistryObject<Item> METEORITE_SHEARS =
            register("meteorite_shears", () ->
                    new ShearsItem(new Item.Properties()));
    public static final RegistryObject<Item> MITHRIL_SHEARS =
            register("mithril_shears", () ->
                    new ShearsItem(new Item.Properties()));

    public static final RegistryObject<Item> ORICHALCUM_SWORD =
            register("orichalcum_sword", () ->
                    new SwordItem(EModTiers.ORICHALCUM, 3, -2.4F, new Item.Properties()));
    public static final RegistryObject<Item> SATURNIUM_SWORD =
            register("saturnium_sword", () ->
                    new SwordItem(EModTiers.SATURNIUM, 3, -3F, new Item.Properties()));
    public static final RegistryObject<Item> BRIMSTONE_SWORD =
            register("brimstone_sword", () ->
                    new SwordItem(EModTiers.BRIMSTONE, 3, -2.4F, new Item.Properties()));
    public static final RegistryObject<Item> METEORITE_SWORD =
            register("meteorite_sword", () ->
                    new SwordItem(EModTiers.METEORITE, 3, -2.4F, new Item.Properties()));
    public static final RegistryObject<Item> MITHRIL_SWORD =
            register("mithril_sword", () ->
                    new SwordItem(EModTiers.MITHRIL, 3, -2.4F, new Item.Properties()));

    /*Thaumstrial's strange item*/
    public static final RegistryObject<Item> BAGUA_COMPASS =
            register("bagua_compass", BaguaCompassItem::new);
    public static final RegistryObject<Item> QIAN_DIAGRAM =
            register("qian_diagram", () -> new Item(new Item.Properties()));
    public static final RegistryObject<Item> KUN_DIAGRAM =
            register("kun_diagram", () -> new Item(new Item.Properties()));
    public static final RegistryObject<Item> ZHEN_DIAGRAM =
            register("zhen_diagram", () -> new Item(new Item.Properties()));
    public static final RegistryObject<Item> XUN_DIAGRAM=
            register("xun_diagram", () -> new Item(new Item.Properties()));
    public static final RegistryObject<Item> KAN_DIAGRAM =
            register("kan_diagram", () -> new Item(new Item.Properties()));
    public static final RegistryObject<Item> LI_DIAGRAM =
            register("li_diagram", () -> new Item(new Item.Properties()));
    public static final RegistryObject<Item> GEN_DIAGRAM =
            register("gen_diagram", () -> new Item(new Item.Properties()));
    public static final RegistryObject<Item> DUI_DIAGRAM =
            register("dui_diagram", () -> new Item(new Item.Properties()));
    public static final RegistryObject<Item> YANG_YAO =
            register("yang_yao", () -> new Item(new Item.Properties()));
    public static final RegistryObject<Item> YIN_YAO =
            register("yin_yao", () -> new Item(new Item.Properties()));
    public static final RegistryObject<Item> TALISMAN =
            register("talisman", TalismanItem::new);

    /*Armor Items*/
    public static final RegistryObject<Item> SILVER_HELMET =
            register("silver_helmet", () ->
                    new ArmorItem(EModArmorMaterials.SILVER, EquipmentSlot.HEAD,
                            new Item.Properties().stacksTo(1)));
    public static final RegistryObject<Item> SILVER_CHEST =
            register("silver_chest", () ->
                    new ArmorItem(EModArmorMaterials.SILVER, EquipmentSlot.CHEST,
                            new Item.Properties().stacksTo(1)));
    public static final RegistryObject<Item> SILVER_LEGGINGS =
            register("silver_leggings", () ->
                    new ArmorItem(EModArmorMaterials.SILVER, EquipmentSlot.LEGS,
                            new Item.Properties()));
    public static final RegistryObject<Item> SILVER_BOOTS =
            register("silver_boots", () ->
                    new ArmorItem(EModArmorMaterials.SILVER, EquipmentSlot.FEET,
                            new Item.Properties()));

    /**
     * Used for registry items
     *
     * @param name Items' registry name
     * @param itemSupplier itemSupplier
     * @param <T>  sth extends Item
     * @return new RegistryObject<Item>
     */
    private static <T extends Item> RegistryObject<T> register(String name, Supplier<T> itemSupplier) {
        return ITEMS.register(name.toLowerCase(Locale.ROOT), itemSupplier);
    }
}
